//
//  SHVideoPusher.swift
//  SHMediaTools
//
//  Created by ace on 2023/6/26.
//

import UIKit
import pili_librtmp

public class SHVideoPusher {
    
    public var rtmpUrl: String = ""
//    private let rtmp: PILI_RTMP = PILI_RTMP()
    
    lazy var rtmp: PILI_RTMP = {
        var error: RTMPError = RTMPError()
        
//        self.rtmpUrl.utf8
        
//        let charArray: [CChar] = self.rtmpUrl.cStringUsingEncoding(NSUTF8StringEncoding)!
        let charStr = self.rtmpUrl.cString(using: .utf8)
        
//        let portalCArray = UnsafeMutablePointer<CChar>(mutating: (self.rtmpUrl as NSString).utf8String!)
        
        var rtmp: PILI_RTMP = PILI_RTMP()
        PILI_RTMP_Init(&rtmp)
        let err = PILI_RTMP_SetupURL(&rtmp, charStr, &error)
        
        return rtmp
    }()
    
    private let startTime: Int = 0
    private let workQueue: DispatchQueue = DispatchQueue(label: "SHVideoPusher")
//    private let
    
    public static let sharedInstance = SHVideoPusher()
    
    public func startRtmpConnect(url: String) {
        
    }
    
    public func stopRtmpConnect() {
        
    }
    
    public init() {}
    
    
    private func initRtmp() {
//        self.rtmp
    }
    
}
